package com.hexiang.web;

import com.hexiang.response.CommonResponse;
import com.hexiang.service.TaskService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class BlockingController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    private final TaskService taskService;

    @Autowired
    public BlockingController(TaskService taskService) {
        this.taskService = taskService;
    }

    @GetMapping(value = "/block",produces = "application/json")
    public CommonResponse executeSlowTask() {
        logger.info("executeSlowTaskStart");
        CommonResponse result = taskService.execute();
        logger.info("executeSlowTaskEnd");

        return result;
    }
}